package cn.usian.controller;

import cn.usian.pojo.Order;
import cn.usian.service.OrderService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("order")
@CrossOrigin(allowedHeaders = "*")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @RequestMapping("{id}")
    public Order findById(@PathVariable("id") Long id){
        return orderService.findById(id);
    }

    @RequestMapping("findPage")
    public Page<Order>findPage(Integer pageIndex, Map pojo){
        return orderService.findPage(pageIndex,pojo);
    }

    @RequestMapping("add")
    public void add(@RequestBody Order order){
        orderService.add(order);
    }

    @RequestMapping("del")
    public void del(Integer id){
        orderService.del(id);
    }
}
